--- 河流水位传感器, dtype(11)
module(..., package.seeall)

local logtag = "RIVER"
local cid, uid = 1, 3 -- 默认用3通道
local dtu, udtu = {}, {} -- 配置文件
local count = 0

local function count(id,mod)
    --上报ACTION,IN,1到服务器
    count = count + 1
    local ACTION =  "ACTION,IN,"..id
    sys.publish("NET_SENT_RDY_" ..cid, ACTION)
    lcd.LCD_DATA[3] = ACTION.." 日累计:"..count
    usrdata.update(count)
 end
function setDtu(dtup, udtup)
    dtu, udtu = dtup, udtup
    log.info(logtag,"河流雨量/水位启动...")
    sys.taskInit(INIT)
end
function INIT()
    sys.subscribe("DTU_KEY_PRESS_1", count)
    sys.subscribe("DTU_KEY_PRESS_2", count)
    sys.subscribe("CLEAR_COUNT", function (v)
        count = v or 0
    end)
    log.info(logtag,"河流雨量/水位启动成功")

    while true do
        sys.wait(5000)
        usrdata.update(count)
    end
end
